﻿@using E5_KhuyenMaiVang.Models;
@model IEnumerable<DEAL>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";   
    List<CATEGORY> Categories = ViewBag.Categories;
    int nDeal = Model.Count();
    double TongDoanhThu = 0;
}

@section menu
{
    <h3>Admin</h3>
    <ul class="nav">        
        <li><a href="@Url.Action("TKDT_Thang","Admin")">Doanh thu theo tháng</a></li>
        <li><a href="@Url.Action("TKDT_KhuyenMai","Admin")" style="text-decoration:underline; font-weight:bold;">Doanh thu khuyến mãi</a></li>
        <li><a href="@Url.Action("TKDT_DoanhNghiep","Admin")">Doanh thu doanh nghiệp</a></li>
   </ul>
}



<div class="top-bar">                   
    <h1>THỐNG KÊ DOANH THU</h1>
    <div class="breadcrumbs"><a href="#">Thống kê</a> / <a href="#">Doanh thu theo khuyến mãi</a></div>
</div>
<form method="post" action="@Url.Action("SearchTKDT_KhuyenMai", "Admin")">
<div class="select-bar">
    <label>
        <select name="CategoryID">
            <option value="0">Tất cả</option>
            @foreach (var item in Categories) {
                if (item.CategoryID != ViewBag.CategoryID)
                {
                <option value="@item.CategoryID">@item.CategoryName</option>
                }
                else { 
                    <option value="@item.CategoryID" selected="true">@item.CategoryName</option>
                }
            }
        </select>
    </label>
    <label>
        <input type="submit" name="Submit" value="Search" />
    </label>
</div>
</form>
<div class="table">
<table class="listing" cellpadding="0" cellspacing="0">
        <tr>
            <th width="69">Số thứ tự</th>
            <th width="194">Tên khuyến mãi</th>
            <th width="69">Ngày đăng</th>
            <th width="69">Ngày hết hạn</th>                           
            <th width="117">Doanh nghiệp</th>
            <th width="39">Giá</th>
            <th width="112">Số lương bán</th>
            <th width="80">Tiền thu</th>
        </tr>
        @for (int i = 0; i < nDeal; i++)
        {
            double TongTien = Model.ElementAt(i).Discount * Model.ElementAt(i).SoldQuantity;
            TongDoanhThu += TongTien;
        <tr>
            <td class="style1">@(i+1)</td>
            <td>@Model.ElementAt(i).DealName</td>
            <td>@Model.ElementAt(i).StartDate</td>
            <td>@Model.ElementAt(i).EndDate</td>
            <td>@Model.ElementAt(i).COMPANY.CompanyName</td>
            <td>@Model.ElementAt(i).Discount</td>
            <td>@Model.ElementAt(i).SoldQuantity</td>
            <td>@TongTien</td>
                           
        </tr>
        }
    </table>
    <div class="select">
        <strong>Tổng doanh thu: </strong>
        <strong style="color:#F00;">@TongDoanhThu</strong>
    </div>
</div>
            